export function buildTree<T>(data:any, pid:number= 0) {
    let tree:any = [];

    data.forEach((node:any) => {

      if (node.pid == pid) {
        let children = buildTree(data, node.id);
        if (children.length) {
          node.children = children;
        }
        tree.push(node);
      }
    });
    return tree;
  }